/**
 * 
 */
package com.et114.core.utility;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

import com.et114.core.common.CONST;


/*
 * @author guanhw
 */
public class ConfigUtil {
	private  static Configuration config; 
	public  Configuration getConfiguration(  ) throws Exception {
		if( config == null){
			try {
				config = new PropertiesConfiguration( getClass().getClassLoader()
						.getResource( CONST.CONFIG_NAME ) );
			} catch ( ConfigurationException e ) {
				e.printStackTrace();
			}
		}
		return config;
	}
	
	public  Configuration getConfiguration( String config_ ) throws Exception {
		if( config == null){
			try {
				config = new PropertiesConfiguration( getClass().getClassLoader()
						.getResource( config_ ) );
			} catch ( ConfigurationException e ) {
				e.printStackTrace();
			}
		}
		return config;
	}	
	
	public static Configuration getConfig()   throws Exception { 
		return new ConfigUtil().getConfiguration() ;
	}
	
}
